<?php
	/**
	* Country Edit
	* @author trungdt
	* @since Apr 14, 2011 
	* 
	* Change logs
	* 
	*/
	if (!defined('EXPONENT')) exit('');
	$id=0;
	$country=null;
	$config=null;
	//$country = $db->selectObject('geolocationmodule_country','location_data='.serialize($loc));
	if (isset($_REQUEST['id'])) {
		$country = $db->selectObject('bannermediamodule_item','id='.intval($_REQUEST['id']));
		$config=null;
		if ($country) {
			$loc = unserialize($country->location_data);
			$id=$country->id;
		}
	}
    $config = $db->selectObject('bannermediamodule_config',"location_data='".serialize($loc)."'");
    if ($config == null) {
            $config->ewidth = 0;
            $config->eheight = 0; // Ascending
            $config->iwidth=0;
            $config->iheight=0;
            }
	if (exponent_permissions_check(array('administrate','configure',"create","edit","delete"),$loc)) 
	{   
		$form = bannermedia::bannermedia_form($country);
		$form->location($loc);
        $form->meta('module','bannermediamodule');   
		$form->meta('action','bannermedia_save');
		$template = new template('bannermediamodule','_bannermedia_edit');
		
		// load language file
		$i18n=exponent_lang_loadFile("/modules/bannermediamodule/common.php");
		$title = $i18n['bannermedia_add_title'];
		if (isset($country->id))
			$title = $i18n['bannermedia_edit_title'];
		_ab_theme_action_register_title($title);
	   
		$template->assign('title',$title);
		$template->assign('form_html',$form->toHTML());
		$template->output();
	} else {
		echo SITE_404_HTML;
	}
?>